package com.study.mybatis.objectFactory;

import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
import org.apache.ibatis.reflection.factory.ObjectFactory;

import java.util.ArrayList;
import java.util.List;

public class MyObjectFactory implements ObjectFactory {
    @Override
    public <T> T create(Class<T> type) {
        DefaultObjectFactory ds;
        try {
            System.out.println("create1");
            if (type == List.class) return (T) new ArrayList();
            return type.newInstance();
        } catch (Exception e) {
            return null;
        }
    }

    @Override
    public <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
        System.out.println("create2");
        return null;
    }

    @Override
    public <T> boolean isCollection(Class<T> type) {
        return true;
    }
}